package imageEditor;

import java.awt.Color;
import java.awt.image.BufferedImage;

public class PngImage {

	public static Color getColor(int x, int y, BufferedImage i) {
		if ((x < 0) || (x >= i.getWidth()) || (y < 0) || (y > i.getHeight())) {
			return new Color(0, 0, 0, 0);
		}

		int color = i.getRGB(x, y);

		//System.out.println("Red: " + ((color & 0x00FF0000) >> 16) + "\nGreen: " + ((color & 0x0000FF00) >> 8) + "\nBlue: " + (color & 0x000000FF) + "\nAlpha: " + ((color & 0xFF000000) >> 24) + "\n\n");

		return new Color(((color & 0x00FF0000) >> 16), ((color & 0x0000FF00) >> 8), (color & 0x000000FF), (((color & 0xFF000000) >> 24) < 0 ? 255
				: ((color & 0xFF000000) >> 24)));
	}

}
